import {getCount} from '@/api/upms/syscustomer'

const validatePhone = (rule, value, callback) => {
  if (window.openType === 'edit'){
    callback()
  }else{
    getCount({
      phone: value
    }).then(response => {
      let data = response.data.data
      if (data > 0) {
        callback(new Error('手机号码已经存在'))
      } else {
        callback()
      }
    })
  }
}

export const tableOption = {
    dialogDrag: true,
    border: true,
    index: true,
    indexLabel: '序号',
    stripe: true,
    menuAlign: 'center',
    align: 'center',
    menuType: 'text',
    searchShow: true,
    excelBtn: true,
    printBtn: true,
    viewBtn: true,
    searchMenuSpan: 6,
    column: [
            {
            label: '姓名',
            prop: 'name',
            sortable: true,
              search: true,
            rules: [{
              required: true,
              message: '请输入姓名'
            }]
        },

      {
        label: '电话',
        search: true,
        prop: 'phone',
        value: '',
        sortable: true,
        rules: [{
          required: true,
          message: '请输入手机号'
        },{
          min: 11,
          max: 11,
          message: '长度在 11 个字符',
          trigger: 'blur'
        },{
          validator: validatePhone,
          trigger: 'blur'
        }]
      },
            {
              label: '性别',
              prop: 'sex',
              type: 'radio',
              sortable: true,
              dicData: [{
                label: '男',
                value: '1'
              }, {
                label: '女',
                value: '2'
              }]
        },
      {
        label: '年龄',
        prop: 'age',
        sortable: true,
      },


            {
            label: '信息渠道',
              search: true,
            prop: 'channel',
              type: 'select',
              sortable: true,
              dicData: [{
                label: '会员介绍',
                value: '0'
              }, {
                label: '企业推广',
                value: '1'
              }, {
                label: '朋友圈',
                value: '2'
              }, {
                label: '抖音',
                value: '3'
              }, {
                label: '员工介绍',
                value: '4'
              }, {
                label: '广告',
                value: '5'
              }, {
                label: '其他',
                value: '6'
              }]
        },
            {
            label: '俱乐部',
            prop: 'club',
            sortable: true,
            rules: [
                                ]
        },
            {
            label: '打球地点',
            prop: 'playPlace',
            sortable: true,
            rules: [
                                ]
        },
      {
        label: '打球时间',
        search: true,
        prop: 'playTime',
        sortable: true,
        type: 'cascader',
        rules: [],
        dicData: [
          {
            label: '节假日',
            value: '11',
            children: [{
              label: '早场',
              value: '0'
            }, {
              label: '8:00-10:00',
              value: '1'

            }, {
              label: '10:00-12:00',
              value: '2'

            }, {
              label: '15:00-17:00',
              value: '3'

            }, {
              label: '17:00-19:00',
              value: '4'
            }, {
              label: '晚场',
              value: '5'
            }]
          },
          {
            label: '周一到周五',
            value: '22',
            children: [{
              label: '早场',
              value: '0'
            }, {
              label: '8:00-10:00',
              value: '1'

            }, {
              label: '10:00-12:00',
              value: '2'

            }, {
              label: '15:00-17:00',
              value: '3'

            }, {
              label: '17:00-19:00',
              value: '4'
            }, {
              label: '晚场',
              value: '5'
            }]
          },
          {
            label: '周一到周日',
            value: '33',
            children: [{
              label: '早场',
              value: '0'
            }, {
              label: '8:00-10:00',
              value: '1'

            }, {
              label: '10:00-12:00',
              value: '2'

            }, {
              label: '15:00-17:00',
              value: '3'

            }, {
              label: '17:00-19:00',
              value: '4'
            }, {
              label: '晚场',
              value: '5'
            }]
      }]},
      {
        label: '职业',
        prop: 'occupation',
        sortable: true,
        type: 'select',
        rules: [],
        dicData: [{
          label: '教学人员',
          value: '0'
        }, {
          label: '运动员',
          value: '1'
        },{
          label: '工程师',
          value: '2'
        }, {
          label: '工人',
          value: '3'
        },{
          label: '军人',
          value: '4'
        }, {
          label: '专业技术人员',
          value: '5'
        },{
          label: '党的机关、国家机关、群众团体和社会组织、企事业单位负责人',
          value: '6'
        }, {
          label: '失业、无业或离退休',
          value: '7'
        }, {
          label: '其他',
          value: '8'
        }]
      },
      {
            label: '消费能力',
            prop: 'capacity',
            sortable: true,
            rules: [
                                ]
        },
            {
            label: '家庭住址',
            prop: 'address',
            sortable: true,
            rules: [
                                ]
        },
            {
            label: '是否有孩子',
            prop: 'kid',
              type: 'radio',
              sortable: true,
              dicData: [{
                label: '是',
                value: '0'
              }, {
                label: '否',
                value: '1'
              }]
        },
            {
            label: '孩子的情况',
            prop: 'kidSituation',
            sortable: true,
            rules: [
                                ]
        },
            {
            label: '球龄',
            prop: 'playYear',
            type: 'number',
            sortable: true,
            rules: [
                                ]
        },
            {
            label: '意向产品',
            prop: 'intendedProducts',
              search: true,
            sortable: true,
              multiple:true,
              type: 'select',
            rules: [],
              dicData: [{
                label: '羽毛球会员卡',
                value: '0'
              }, {
                label: '羽毛球成人培训班',
                value: '1'
              }, {
                label: '羽毛球青少年培训班',
                value: '2'
              }, {
                label: '篮球青少年培训班',
                value: '3'
              }, {
                label: '民族舞',
                value: '4'
              }, {
                label: '街舞',
                value: '5'
              }, {
                label: '围棋',
                value: '6'
              }, {
                label: '跆拳道',
                value: '7'
              }, {
                label: '体育培训',
                value: '8'
              }]
        },
            {
            label: '下次跟进时间',
            prop: 'followTime',
              type: 'date',
              valueFormat: 'yyyy-MM-dd HH:mm:ss',
            sortable: true,
            rules: [
                                ]
        },
      {
        label: '所属用户id',
        prop: 'userId',
        hide:true,
        sortable: true,
        display:false,
        addDisplay: false,
        editDisplay: false,
        rules: [
        ]
      },
      {
        label: '所属用户',
        prop: 'userName',
        search: true,
        sortable: true,
        addDisplay: false,
        editDisplay: false,
        rules: [
        ]
      },
      {
        label: '日期',
        prop: 'date',
        type: 'date',
        sortable: true,
        addDisplay: false,
        editDisplay: false,
        valueFormat: 'yyyy-MM-dd HH:mm:ss',
        rules: [],
      },
      {
        label: '客户等级',
        prop: 'rating',
        sortable: true,
        search: true,
        type: 'select',
        rules: [],
        dicData: [{
          label: 'A+',
          value: '0'
        }, {
          label: 'A',
          value: '1'
        }, {
          label: 'B',
          value: '2'
        }, {
          label: 'C',
          value: '3'
        }]
      },
      {
        label: '打球频率',
        search: true,
        prop: 'frequency',
        sortable: true,
        type: 'select',
        rules: [],
        dicData: [{
          label: '每天一次',
          value: '0'
        }, {
          label: '一周两次',
          value: '1'
        }, {
          label: '一周三次',
          value: '2'
        }, {
          label: '一周一次',
          value: '3'
        }, {
          label: '一月一次',
          value: '4'
        }]
      },
      {
        label: '办卡情况',
        prop: 'applyCard',
        type: 'select',
        search: true,
        sortable: true,
        addDisplay: false,
        editDisplay: false,
        dicData: [{
          label: '未办卡',
          value: '0'
        }, {
          label: '已办卡',
          value: '1'
        }]
      },
      {
        label: '会员备注',
        prop: 'remarks',
        search: true,
        sortable: true,
      },
  ]
}
